﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Dialog.Master" AutoEventWireup="true"
    CodeBehind="SaleDiscountEdit.aspx.cs" Inherits="SaleDiscount.Portal.SaleDiscountEdit" %>

<%@ Register TagPrefix="uc1" Namespace="SaleDiscount.Portal.Controls" Assembly="SaleDiscount.Portal" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script language="javascript" type="text/javascript">
        var userDialogSize = { width: 850, height: window.top.$common.getClientBounds().height - 100 };
        function chooseListings() {

            $dialog('<%=ResolveUrl("~/ChooseListing.aspx") %>', userDialogSize, function (result) {
                if (result) {
                    var data = JSON.parse(result);
                    $text($get('<%=fieldListingIds.ClientID %>'), data.ItemIds);
                    $get('<%=btnReload.ClientID %>').click();
                }
            });
        }
        
        function clearListings() {
            $confirm("All listings associated with this sale will be removed from this sale. Are you sure you want to clear all listings?", function (result) {
                if (result) {
                    $text($get('<%=fieldListingIds.ClientID %>'), "");
                }
            });
 
        }


        
        
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
        <tr>
            <td>
                <NetDon:FormPanel ID="panelCustomInfo" runat="server" CaptionAlign="NotSet" RepeatColumns="1">
                    <Items>
                        <NetDon:FormItem FullRow="True" HeaderVisible="False">
                            <ContentTemplate>
                                <asp:Literal ID="Literal3" runat="server" Text="Choose a name and dates for your sale"></asp:Literal>
                            </ContentTemplate>
                            <ContentStyle ForeColor="#037CC6" Font-Bold="true"></ContentStyle>
                        </NetDon:FormItem>
                        <NetDon:FormItem HeaderText="Choose a sale title">
                            <ContentTemplate>
                                <asp:TextBox ID="txtSaleName" runat="server" Text='<%#Bind("SaleName") %>'>
                                </asp:TextBox>
                                <br />
                                Your sale title won't appear to buyers.
                                <uc1:RequiredMark ID="RequiredMark2" runat="server" />
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtSaleName"
                                    Display="None" ErrorMessage="Please enter this information." SetFocusOnError="True"></asp:RequiredFieldValidator>
                            </ContentTemplate>
                        </NetDon:FormItem>
                        <NetDon:FormItem HeaderText="Choose a start date" Key="formItemStartDate">
                            <ContentTemplate>
                                <asp:TextBox ID="txtStartDate" Text='<%#Eval("StartDate") != null ? ((DateTime)Eval("StartDate")).ToString("MM/dd/yyyy") : ""%>'
                                    Width="120px" runat="server"></asp:TextBox>
                                <asp:DropDownList ID="txtStartDateHour" AppendDataBoundItems="True" runat="server" Width="50px">
                                </asp:DropDownList>
                                <asp:DropDownList ID="txtStartDateMinute" AppendDataBoundItems="True" runat="server"  Width="50px">
                                </asp:DropDownList>
                                US Time (PDT)
                                <uc1:RequiredMark ID="RequiredMark5" runat="server" />
                                <asp:CalendarExtender ID="txtStartShippmentDateCalendarExtender2" runat="server"
                                    Animated="False" Enabled="True" FirstDayOfWeek="Sunday" TargetControlID="txtStartDate"
                                    Format="MM/dd/yyyy">
                                </asp:CalendarExtender>
                                <asp:CustomValidator ID="txtDriverOnboardDateCustomValidator2" ClientValidationFunction="validateDateText"
                                    runat="server" ErrorMessage="please choose vaild start date." Display="None"
                                    ControlToValidate="txtStartDate" OnServerValidate="DateValidator_ServerValidate"></asp:CustomValidator>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtStartDate"
                                    Display="None" ErrorMessage="please enter start date" SetFocusOnError="True"></asp:RequiredFieldValidator>
                                <br />
                                The maximum sale length is 45 days (does not apply to auctions).
                            </ContentTemplate>
                        </NetDon:FormItem>
                        <NetDon:FormItem HeaderText="Choose a end date"  Key="formItemEndDate">
                            <ContentTemplate>
                                <asp:TextBox ID="txtEndDate" Text='<%#Eval("EndDate") != null ? ((DateTime)Eval("EndDate")).ToString("MM/dd/yyyy") : ""%>'
                                    Width="120px" runat="server"></asp:TextBox>
                                <asp:DropDownList ID="txtEndDateHour" AppendDataBoundItems="True" runat="server"  Width="50px">
                                </asp:DropDownList>
                                <asp:DropDownList ID="txtEndDateMinute" AppendDataBoundItems="True" runat="server"  Width="50px">
                                </asp:DropDownList>
                                US Time (PDT)
                                <uc1:RequiredMark ID="RequiredMark3" runat="server" />
                                <asp:CalendarExtender ID="CalendarExtender1" runat="server" Animated="False" Enabled="True"
                                    FirstDayOfWeek="Sunday" TargetControlID="txtEndDate" Format="MM/dd/yyyy">
                                </asp:CalendarExtender>
                                <asp:CustomValidator ID="CustomValidator1" ClientValidationFunction="validateDateText"
                                    runat="server" ErrorMessage="please choose vaild start date." Display="None"
                                    ControlToValidate="txtStartDate" OnServerValidate="DateValidator_ServerValidate"></asp:CustomValidator>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtStartDate"
                                    Display="None" ErrorMessage="please enter start date" SetFocusOnError="True"></asp:RequiredFieldValidator>
                                <br />
                                The maximum sale length is 45 days (does not apply to auctions).
                            </ContentTemplate>
                        </NetDon:FormItem>
                        <NetDon:FormItem FullRow="True" HeaderVisible="False">
                            <ContentTemplate>
                                <asp:Literal ID="Literal1" runat="server" Text="Choose your discount"></asp:Literal>
                            </ContentTemplate>
                            <ContentStyle ForeColor="#037CC6" Font-Bold="true"></ContentStyle>
                        </NetDon:FormItem>
                        <NetDon:FormItem HeaderVisible="False">
                            <ContentTemplate>
                                <asp:CheckBox runat="server" ID="ckbIsAuctionExcluded" Text="Price discount (auctions excluded) " Checked="True" AutoPostBack="True" OnCheckedChanged="ckbIsAuctionExcluded_CheckedChanged"/><br/>
                                <asp:RadioButton runat="server" GroupName="discount" ID="radioDiscountRatio" Text="Offer a percentage off the original price " Checked="True" OnCheckedChanged="radioDiscountRatio_CheckedChanged" AutoPostBack="True" />
                                <asp:TextBox ID="txtDiscountRatio" runat="server" MaxLength="9" Width="60px" Style="text-align: right"></asp:TextBox>%
                                <br />
                                <uc1:RequiredMark ID="RequiredMark1" runat="server" />
                                <asp:RequiredFieldValidator ID="RequiredFieldValidatorDiscountRatio" runat="server" ControlToValidate="txtDiscountRatio"
                                    Display="None" ErrorMessage="plese enter a valid number (percentage) between 5 and 75."
                                    SetFocusOnError="True"></asp:RequiredFieldValidator>
                                <NetDon:NumericEditExtender ID="NumericEditExtenderDiscountRatio" runat="server" TargetControlID="txtDiscountRatio"
                                    DataMode="Double" MinValue="5" MaxValue="75">
                                </NetDon:NumericEditExtender>
                                <asp:RadioButton runat="server" GroupName="discount" ID="radioDiscountAmount" Text="Discount the original price by a set amount" OnCheckedChanged="radioDiscountRatio_CheckedChanged" AutoPostBack="True" />
                                <asp:TextBox ID="txtDiscount" runat="server" MaxLength="9" Width="60px" Style="text-align: right"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidatorDiscount" runat="server" ControlToValidate="txtDiscount"
                                    Display="None" ErrorMessage="plese enter Please enter this information." SetFocusOnError="True"></asp:RequiredFieldValidator>
                                <NetDon:NumericEditExtender ID="NumericEditExtenderDiscount" runat="server" TargetControlID="txtDiscount"
                                    DataMode="Double">
                                </NetDon:NumericEditExtender>
                                <br />
                                <asp:CheckBox runat="server" ID="ckbIsFreeshipping" Text="Free Shipping (applies to the first U.S. shipping service)" />
                            </ContentTemplate>
                        </NetDon:FormItem>
                        <NetDon:FormItem FullRow="True" HeaderVisible="False">
                            <ContentTemplate>
                                <asp:Literal ID="Literal2" runat="server" Text="Choose your listings"></asp:Literal>
                            </ContentTemplate>
                            <ContentStyle ForeColor="#037CC6" Font-Bold="true"></ContentStyle>
                        </NetDon:FormItem>
                        <NetDon:FormItem  HeaderVisible="False">
                            <ContentTemplate>
                                <asp:Panel runat="server" ID="panelForModify">
                                       <span>Modify the listings to this sale. Any listings currently on sale will appear in this sale only once it starts. These settings will not apply to future listings. </span>
                                </asp:Panel>
                             <asp:Panel runat="server" ID="panelForAdd">
                                  <span>There are three ways to select your listings by category, by format, or by individual
                                    listing.</span>
                                <br />
                                <span>Note: If you add listings that are already on sale, they will be moved into this
                                    sale. </span>
                                <br />
                             </asp:Panel>
                               
                                <asp:CheckBox runat="server" ID="CheckBoxAddAllListingsFromCategory" Text="Add all listings from a category" /><br />
                                <asp:DropDownList ID="ddlStoreCategory" AppendDataBoundItems="True" runat="server">
                                </asp:DropDownList><br/>
                                <asp:CheckBox runat="server" ID="CheckBoxAddAllActiveFixedPriceListings" Text="Add all active Fixed Price listings" /><br/>
                                <asp:CheckBox runat="server" ID="CheckBoxAddAllActiveAuctionListings" Text="Add all active Auction-style listings" /><br />
                                <span>Only free shipping can be selected for auction listings. </span>
                            </ContentTemplate>
                        </NetDon:FormItem>
                        <NetDon:FormItem HeaderVisible="False">
                            <ContentTemplate>
                                <asp:LinkButton ID="hyperLinkSelectListings" runat="server" Text='Select listings individually'>
                                </asp:LinkButton>
                                <span id="spanSeperator" runat="server">&nbsp;|&nbsp;</span>
                                <asp:LinkButton ID="hyperLinkClearListings" runat="server" Text='Clear listings'>
                                </asp:LinkButton>
                            </ContentTemplate>
                        </NetDon:FormItem>
                    </Items>
                </NetDon:FormPanel>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <div style="padding-top: 10px">
                    <center>
                        <asp:Button ID="btnSave" runat="server" SkinID="Button120" Text="Create your sale"
                            OnClick="btnSave_Click"></asp:Button>
                        <asp:Button ID="btnReturn" runat="server" Text="Cancel" CausesValidation="false">
                        </asp:Button>
                        <asp:HiddenField ID="fieldListingIds" runat="server" />
                         <asp:Button ID="btnReload" runat="server" SkinID="Hidden" OnClick="btnReload_Click" />
                        <NetDon:ValidationSummary ID="ValidationSummary2" runat="server" ShowMessageBox="true"
                            ShowSummary="false" />
                        <br />
                        <br />
                        <br />
                    </center>
                </div>
            </td>
        </tr>
    </table>
</asp:Content>
